package com.entor.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.entor.dao.IncomeDaoI;
import com.entor.model.Income;
import com.entor.model.Msg;

@Service
public class IncomeService implements BaseServiceI<Income>{

	@Autowired
	private IncomeDaoI idi;
	
	
	public List<Income> find(Income t) {
	List<Income> list=idi.find(t);
	
		return list;
	}

	public Income get(Income t) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg insert(Income t) {
		Double con=t.getCocin()+t.getSpein()+t.getPartyin()+t.getElsein()-t.getCocout()-t.getPreout();
		t.setCount(con);
	int i=idi.insert(t);
	Msg m = new Msg("保存失败", false);
	if(i>0){
		m.setMsg("保存成功");
		m.setIs(true);
	}
	return m;
	}

	public Msg batchInsert(String objs) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg edit(Income t) {
		int i=idi.edit(t);
		Msg m = new Msg("更新失败", false);
		if(i>0){
			m.setMsg("更新成功");
			m.setIs(true);
		}
		return m;
	}

	public Msg remove(Integer id) {
		int i=idi.remove(id);
		Msg m = new Msg("删除失败", false);
		if(i>0){
			m.setMsg("删除成功");
			m.setIs(true);
		}
		return m;
	}

	public Msg batchRemove(String ids) {
		// TODO Auto-generated method stub
		return null;
	}

}
